﻿CREATE TABLE [dbo].[Rule] (
    [RuleId]      INT             IDENTITY (1, 1) NOT NULL,
    [ProjectId]   INT             NOT NULL,
	[TargetDataId] BIGINT NOT NULL,
	[TransformationDataId] BIGINT NULL,
    [RuleName]    NVARCHAR (250)  NOT NULL,
	[ShortDescription] NVARCHAR(100) NOT NULL,
	[LoadFrequency] NVARCHAR(200) NULL,
	[MappingSourceDescription] NVARCHAR(2500) NULL,
	[ErrorHandling] NVARCHAR(2500) NULL,
    [Comments] NVARCHAR (2500) NULL,
    CONSTRAINT [PK_Rule] PRIMARY KEY CLUSTERED ([RuleId] ASC),
    CONSTRAINT [FK_Rule_Project] FOREIGN KEY ([ProjectId]) REFERENCES [dbo].[Project] ([ProjectId]), 
    CONSTRAINT [FK_Rule_TargetData] FOREIGN KEY ([TargetDataId]) REFERENCES [dbo].[Data]([DataId]), 
    CONSTRAINT [FK_Rule_TransformationData] FOREIGN KEY ([TransformationDataId]) REFERENCES [dbo].[Data]([DataId]) 
);
GO
